#include "ExpressionFactory.hpp"

#include "Logger.hpp"

#include "Constant.hpp"
#include "Variable.hpp"
#include "RelationBinaire.hpp"
#include "RelationBinaireLogique.hpp"
#include "Minus.hpp"
#include "Not.hpp"
#include "Array.hpp"
#include "Deref.hpp"
#include "Address.hpp"
#include "Call.hpp"

Expression*
ExpressionFactory::generateConstant ( int value )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Constant ( value );
}

Expression*
ExpressionFactory::generateConstant ( float value )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Constant ( value );
}

Expression*
ExpressionFactory::generateConstant ( bool value )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Constant ( value );
}

Expression*
ExpressionFactory::generateConstant ( const char* value )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Constant ( value );
}

Expression*
ExpressionFactory::generateVariable ( const std::string& name )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Variable(name);
}

Expression*
ExpressionFactory::generateAdd ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaire(opGauche,'+',opDroit);
}

Expression*
ExpressionFactory::generateSub ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaire(opGauche,'-',opDroit);
}

Expression*
ExpressionFactory::generateMul ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaire(opGauche,'*',opDroit);
}

Expression*
ExpressionFactory::generateDiv ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaire(opGauche,'/',opDroit);
}
//ici
Expression*
ExpressionFactory::generateMinus ( Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Minus(opDroit);
}

Expression*
ExpressionFactory::generateAnd ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaireLogique(opGauche,RBLAnd,opDroit);
}

Expression*
ExpressionFactory::generateOr ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaireLogique(opGauche,RBLOr,opDroit);
}

Expression*
ExpressionFactory::generateNot ( Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Not(opDroit);
}

Expression*
ExpressionFactory::generateEq ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaireLogique(opGauche,RBLEq,opDroit);
}

Expression*
ExpressionFactory::generateNeq ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaireLogique(opGauche,RBLNeq,opDroit);
}

Expression*
ExpressionFactory::generateLt ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaireLogique(opGauche,RBLLt,opDroit);
}

Expression*
ExpressionFactory::generateLte ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaireLogique(opGauche,RBLLte,opDroit);
}

Expression*
ExpressionFactory::generateGt ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaireLogique(opGauche,RBLGt,opDroit);
}

Expression*
ExpressionFactory::generateGte ( Expression* opGauche, Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new RelationBinaireLogique(opGauche,RBLGte,opDroit);
}

Expression*
ExpressionFactory::generateArray ( Expression* arrayDef, Expression* index )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Array(arrayDef,index);
}

Expression*
ExpressionFactory::generateAddress ( Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Address(opDroit);
}

Expression*
ExpressionFactory::generateDeref ( Expression* opDroit )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Deref(opDroit);
}

Expression*
ExpressionFactory::generateCall ( const std::string& name, std::vector < Expression* > listeExpression )
{
    LOGFUNCTION ( EFACT_LOG );
    return new Call(name,listeExpression);
}
